﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace PitBull.Collection
{
    public static class ObjectHandler
    {
        public static T CopyObject<T>(T input)
        {
            object Output;
            DataContractSerializer serializer = new DataContractSerializer(input.GetType());
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            serializer.WriteObject(ms, input);
            ms.Seek(0, System.IO.SeekOrigin.Begin);
            Output = serializer.ReadObject(ms);
            return (T)Output;
        }
    }
}
